Casio fx-7700GB calculator to Acorn interface program.
Program by Alexander T. Smith. <alexsmith@enterprise.net>
Hardware originally designed by Mike Cook.
See !Graphic.Docs.Credits for a full list of people and organisations who helped realise this project.

Disclaimer.
-----------

The user accepts sole responsibility for the use of the software and hardware. I, nor anyone else named in the documentation can or will be held responsible for hardware damage (to computers or calculators) or for loss of data. Having said that I have made reasonable effort to ensure that the software and hardware work correctly.

Introduction.
-------------

This hardware and software package allows you to use your Acorn 32bit computer to send and recieve programs to and from a Casio fx-7700GB calculator[1]. The program also allows you to:
 - view the programs once they are in the computers memory,
 - load and save individual programs to and from disk,
 - save and load all the programs in the computer to disk in one file.

System requirements.
--------------------

You'll need a 32bit Acorn computer, with a working serial port[2], serial port podules are not supported at the present time. A hard disk would be preferable but not essential and a monitor that can display mode 15 or 28. If you have a floppy disk only system then I would advise having a copy of !Scrap on the same disk as the interface program or in the ram disc.

Setting up the hardware.
------------------------

This depends a lot on the precise details of how the interface you have was made. I will assume you have an interface that I made for you[3]. I recommend turning the computer off before doing anything else. Insert the larger of the two plugs on the interface in to the serial port of the computer, not in to any serial port provided by other expansion cards in the computer[4] (See the 'future' part of this file for more information regarding Serial Drivers). With the calculator turned off insert the smaller plug in to the calculator, you may have to remove a little rubber bung from the socket before you can do this. I recommend you keep the little rubber bung and put it back in afterwards. Check that there is a battery[12] in the interface and turn it on. Now turn on the computer and calculator. 

Note for A3010 users, the A3010 has two joystick sockets placed (wisely?) next to the serial port, the sockets all appear indentical apart from the labels on the computer. Be very sure you use the socket marked RS-232 and *not* any of the joystick ports. If you do plug the calculator interface in to a joystick socket you will defintely damage the joystick port by blowing a fuse inside the computer and you may damage the interface too.

If you are using an interface you made yourself then I'm sure you know what to plug in to where.

Setting up the software.
------------------------

The software is supplied in an ArcFS archive, unless you have the read and write version of ArcFS (the one you have to pay for) then the program must be copied out of the archive to either a floppy or hard disk. I assume the program will work over a network but I have not had chance to try this. Consult the Risc OS user guide for how to copy files, I will put a copy of ArcFS on the disk you send to me to get the software.

When you double click the !Graphic application you will see something like this :

 Casio calculator to Acorn interface program.

Select option :

1. Change parameters. [ Parity : none
                          Baud : 9600 ]
                         Model : fx-7700GB or GE ]"
2. Transmit one program.
3. Receive one program.
4. Interpret program.
5. Save program.
6. Save all programs.
7. Load program.
8. Load all programs.
9. Quit.

This is the main menu, the first thing to do is to check that the calculator and program are using the same parameters, because of hardware limitations[5] you can not set the parity to anything other than none at the computer end so change that in the calculator to the same, also check the the calculator is set to 9600 baud which is fine for most situations. If you are getting checksum errors then you should step down to 4800, then 2400 and 1200. If you are still getting checksum errors then I'd suggest that the interface and or the computer are recieving too much electromagnetic interference[6] and should be moved to a different location, also you can contact me and I'll try to help.

All menu items are selected by pressing the number next to the item, to change to paramters press 1 e.t.c.

Under the main menu you will see a list of red and white munbers, the white numbers are program areas in the computers memory, the program defaults to 38, the same as the calculator. You can change this by editing !Graphic.!Runimage, look in PROCinit, the line to edit is commented with REM statements. Only do this if you need more program areas and you know something about BASIC.

If you press escape or an error occours and the program is at the main menu then the programs in memory (if any) are saved to Wimp$ScrapDir.Dump[7] in case you had not saved them.

To change the parameters.
-------------------------

From the main menu press 1 and then press 1 to change the baud rate, it will cycle through 1200, 2400, 4800, 9600 and back to 1200. Also you can press 2 to tell the computer what model calculator is on the other end. Because there is only one model fully supported (fx-7700GB, I am assuming that the GE model is like the GB but with Casio's fancy menu system bolted on the top). Like with the baud rate pressing 2 will cycle through the available options. When you are satisfied with the options press 0 to return to the main menu. I do intend to implement option saving but not just yet. ;)

To transmit one program.
------------------------

From the main menu press 2, if there are no programs in the computer you will be reminded of this and asked to press space before you can continue. If there is at least one program in the computer then you will be asked to type in the number of the program to send and press return. The program will not accept program numbers that do not exist or are empty and will tell you if you select such a program number. When you have chosen a program to send you will be reminded to set the calculator to recieve one program first before pressing space to send the program. As the program is transmitted it will also be printed on the screen. If the program area in the calculator has a program in it the computer will abort[8] the transfer telling you why.

To recieve one program.
-----------------------

From the main menu press 3, you will be asked which program area in the computer you want the program to be sent to. If this program area (in the computer) is already occupied then you will be asked if you want to choose another program area or to overwrite the program area you have chosen with the program from the calculator. As with transmitting a program the incoming program will also be printed printed to the screen.

To interpret a program.
-----------------------

This option is provided to allow you to study a program as it would appear in the calculators display. If the program is longer than than the available lines on screen you will have to press shift to see some more of the program. When the end of the program is reached press space to go back to the main menu. Because of the way the programs are stored in the calculator it is not easy to edit them externally to the interface program, they are stored in a similar format to BASIC in which all the keywords (sin, cosh, Range e.t.c.)  are represented by one byte each (tokenised).[9]

Saving and loading programs.
----------------------------

These are very similar in operation. Press 5 for save file and 7 for load file from the main menu. These options save individual program areas to disk. You will be asked which program area you want to save and the usual checks are made for the program area existing and having a program in. Then a catalogue of !Graphic.Progs is displayed and you are asked for a filename. Directory names are ignored. If a file of the name you have chosen does not exist then the file is saved. There is no provision for saving over files (with confirmation) as yet. Loading a program file is very similar, you are asked for a program area number and then a filename. The only difference is that you can replace a program in the computers memory with one from disk upon loading. To access the !Graphic.Progs directory in the desktop hold down shift and double click !Graphic, now double click the Progs directory to open it in the usual way.[10]

Saving and loading dumps.
-------------------------

These are also very similar, a dump is all the programs in memory saved in to one big file. This is ideal for backing up the contents of your calculator for when you change the batteries or for when you have to delete the programs when using the calculator in an exam. From the main menu press 6 to save a dump or 8 to load one. If there are no programs in memory then you can not save a dump. If you try and load a dump when there is at least one program in memory you will be given the option of either cancelling the load or overwriting the programs in memory with those in the dump file.

Quitting.
---------

When you press 9 from the main menu you will be asked if you are sure. If you answer yes then the program will quit. If you answer no the program will go back to the main menu.
+---------------------------------------------------------------------------------+
| Note that *no* check is made to ensure that programs in memory have been saved. |
| If you quit without saving any programs then there is no way to get them back.  |
+---------------------------------------------------------------------------------+

Buying/making an interface and contact details.
----------------------------------------

As in reference 3 below I can make interfaces for those not confident in making their own. I will only cover my own costs for parts and postage e.t.c. Please tell me how much cable you want on the interface, clearly A3000/3010/3020 users don't need as much as proper desktop machines do. I haven't found a practical limit on the length. My prototype has about 2 metres of [screened] cable and works fine at 9600 baud. The version 2 interface will only require one 9v battery (unlike the prototype). As for power supply if you want a socket for a mains adapter or other requirements then ask.

As for making your own interface then see !Graphic.Docs.Hardware

You can write to me at:

Alexander T. Smith,
7, Park Lane,
Walney Island,
Barrow-in-Furness,
Cumbria. (UK)
LA14 3AE

If you phone (01229) 470961 then I might be in !

Future.
-------

Apart from reference 4 below I'd also like to be able to print programs, that is not trivial considering all those user defined graphics I have. I think the best solution is to redirect screen output to a sprite and save that. Then you can drop it in to !Draw and resize it sensibly or cut it up in !Paint first for multiple coloumn printouts. A longer term goal is to write an emulator so you can edit and test calculator programs on your computer. It may well have nicer access to all the different functions rather than the little menu system the calculator has at the moment. If you fancy the challenge of rewriting my program so it multitasks under Risc OS and even any of the improvements I have (or haven't) mentioned then I will happily provide as much information as I can. Please let me know if you modify my program, If I think it is a good idea it will be incorporated in future releases.

Other notes.
------------

[1] I intend to add support for other models of calculator as and when I get the information, for the fx-7700GB the details were supplied by Bob Parish (address withheld by request) who also checked out the price of the 'official' interface and software and was similarly horrified. He did have the luxury of some test equipment (RS232 snooping kit) which allowed him to elucidate the protocol relatively easily. He also provided a BASIC program and construction details for a PC version of my program which he has said I can freely distribute so just ask if you want it. I should point out that :
(a) My program is definitely not based on any of his code.
(b) I can't guarantee that a program saved from my program will load in to his and vice versa.

[2] This rules out A3000 users unless you have had the serial port chips fitted, I do not know how to check for the presence or absence of these chips either in the program or by lifting the lid of the machine.

[3] If your soldering skills are limited I can make an interface for you. Check with me first for the current price, which depends on the price of the components. I do not intend to make any profit from this. Also include a formatted floppy disk for the software.

[4] I intend to add support for the serial blockdrivers which would allow any serial port to be used.

[5] The calculator uses 8bits with one or 2 stops bits (2 on Tx and 1 on Rx) the serial port SWIs do not allow the selection 8 bits *and* parity. 8N1 and 8N2 are Ok though.

[6] This situation is really unlikely, its is more likely to be due to a faulty interface or dead batteries. If you can't get one of my interfaces to work then send it back and I will try to fix it.

[7] This why I suggest having !Scrap handy.

[8] It should be possible to force the calculator (from the computer) to overwrite the destination program area with the incoming program, indeed Bob has detailed this in his protocol but I can't get it to work. If the calculator says the program area has a program in it already the computer aborts the program send.

[9] Eventually I will write an editor for these programs, unless someone writes a Zap Casio mode first. The problem with that is that there isn't a font with all the necessary special characters defined. If you want to know what token represents what char/symbol/keyword then have a look at table$() within the program. If you run the program from the CLI (f12 not Control-f12) when you quit it you can type something like FOR i%=0 to 254:PRINT table$(i%):NEXT at the BASIC prompt. Speaking of taskwindows I can't really reccommend you run the program in a taskwindow.

[10] One neat thing about having the programs on disk is you can substitute all the uppercase chars with lower case ones. The calculator doesn't mind these in comments or between " marks, it doesn't understand them in actual equations/expressions though. Have a look at !Graphic.Progs.name in a text editor (I'm firmly in the !Zap camp here). In byte mode it looks like :

00000000 : 3A 22 0D 54 68 69 73 20 63 61 6C 63 75 6C 61 74 : :".This calculat
00000010 : 6F 72 20 62 65 6C 6F 6E 67 73 20 74 6F 3A 0D 0D : or belongs to:..
00000020 : 41 2E 54 2E 53 6D 69 74 68 40 4E 63 6C 0D 22 0C : A.T.Smith@Ncl.".
                                                                                [11]

The first character of a program is always a colon, if you want to write something like the above then you must put a colon at the start or it won't work. The character 0D (hex) is used as CR. The final byte is a checksum (See !Graphic.Docs.Protocol for how to calculate it. If you are writing your own program then you can leave this byte off because the interface program calculates checksums as it sends the program.

[11] That email address will probably not be valid by the time you read this, try alexsmith@enterprise.net instead.

[12] I can't really reccommend using rechargeble batteries (either NiCd or MiMH) because they tend to be used in high current applications. This interface uses just a few mA of current, barely enough to light an LED. Rechargeable batteries do work but Alkaline batteries are far more suited to this type of application. Like with all batteries don't leave them in the interface for long periods of time.